@extends('layout.admin')
@section('content')

        <!-- 内容区域 -->
        <div class="tpl-content-wrapper">

            <div class="container-fluid am-cf">


 

                <div class="row">

                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">添加商品</div>
                                <div class="widget-title am-fl"><?php   ?></div>
                                <div class="widget-function am-fr">
                                    <a href="javascript:;" class="am-icon-cog"></a>
                                </div>
                            </div>
                            <div class="widget-body am-fr">

                                <form class="am-form tpl-form-border-form" id="photoForm" action="/shopadd" method="POST" enctype="multipart/form-data">
                                   
                                 {!! csrf_field() !!}
<!-- 
                商家ID -->
                <?php  $id=session('homeInfo')->id; ?>
            <input type="hidden" value="<?php echo $id; ?>" name="mid">


                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-12 am-form-label am-text-left">商品名称<span class="tpl-form-line-small-title"></span></label>
                                        <div class="am-u-sm-12">
                                            <input type="text" required="required" name="name" class="tpl-form-input am-margin-top-xs" id="user-name">
                                      
                                        </div>
                                    </div>

                                     <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-12 am-form-label am-text-left">商品简介<span class="tpl-form-line-small-title"></span></label>
                                        <div class="am-u-sm-12">
                                            <input type="text" required="required" name="intro" class="tpl-form-input am-margin-top-xs" id="user-name" >
                                         
                                        </div>
                                    </div>

                                 <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-12 am-form-label am-text-left">商品栏目<span class="tpl-form-line-small-title"></span></label>
                                        <div class="am-u-sm-12">
                                           <select name="part_id" class="tpl-form-input am-margin-top-xs" id="user-name" >
                                            @foreach($cats as $cat)
                                            @if($cat->parent_id)
                                            <option value="{{$cat->cat_id}}" style="background-color:gray;">{{$cat->cat_name}}</option>
                                            @endif
                                            @endforeach
                                            </select>
                                        </div>
                                    </div>


                                 <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-12 am-form-label am-text-left">商品分类<span class="tpl-form-line-small-title"></span></label>
                                        <div class="am-u-sm-12">
                                            <select name="column_id" class="tpl-form-input am-margin-top-xs" id="user-name" >
                                           
                                            @foreach($col as $cat)
                                          
                                            <option value="{{$cat->id}}" style="background-color:gray;">{{$cat->column}}</option>
                                           
                                            @endforeach
                                            </select>
                                         
                                        </div>
                                    </div>



                                     <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-12 am-form-label am-text-left">商品单价<span class="tpl-form-line-small-title"></span></label>
                                        <div class="am-u-sm-12">
                                            <input type="text" name="money" required="required" onkeyup="value=value.replace(/[^1234567890-]+/g,'')" class="tpl-form-input am-margin-top-xs" id="user-name"  >
                                      
                                        </div>
                                    </div>







 
                 <hr>
                                                 <div style="height:50px;width:30px;float:left;"></div>
                               
                                   {!! csrf_field() !!}
                                     <div class="am-form-group">
                                        <label for="user-weibo" class="am-u-sm-12 am-form-label  am-text-left">logo图片 <span class="tpl-form-line-small-title"></span></label>
                                        <div class="am-u-sm-12 am-margin-top-xs">
                                            
                                            
                                                  
                                               
                                     
    
                                                <input  name="photo" required="required" type="file" multiple=""><br>
                                                <input type="button" value="预览" onclick="loo()">
                                               <br><br>

                                            <div style="height:200px;width:200px;border:bink solid 2px;">
                                      
                                                <img id="avatar_url" src="" height="200px" width="200px">
                                        </div><br>
                                          <input type="submit" value="提交">
<hr>

                                        </div>
                                      
                                    </div>

                                    
 
 

                                  </form>
     
         
                                    
 
 

                                  </form>

                               
                            </div>
                        </div>
                    </div>
                </div>


            </div>
        </div>
    </div>
    </div>

<script>

 $.ajaxSetup({
        headers: { 'X-CSRF-TOKEN' : '{{ csrf_token() }}' }
    });
   function loo(){
    var formData = new FormData($("#photoForm")[0]);
       
        $.ajax({
            url: "{{url('/look')}}",
            type: 'POST',
            data: formData,
            contentType: false,
            processData: false,
            success: function (returndata) {
               
                $("#avatar_url").attr('src',returndata);
            },
            error: function (returndata) {
                console.log(returndata);
            }
        });
   }

      function loo2(){
    var formData = new FormData($("#photoForm2")[0]);
       
        $.ajax({
            url: "{{url('/look2')}}",
            type: 'POST',
            data: formData,
            contentType: false,
            processData: false,
            success: function (returndata) {
            
                $("#avatar_url2").attr('src',returndata);
            },
            error: function (returndata) {
                console.log(returndata);
            }
        });
   }
</script>

<script>
           $("input[name='name']").focusout(function() {
            if(!($(this).val())){
                $(this).attr('placeholder','请输入商品名');
            }
        });

           $("input[name='intro']").focusout(function() {
            if(!($(this).val())){
                $(this).attr('placeholder','请输入商品名信息');
            }
        });



            $("input[name='money']").focusout(function() {
            if(!($(this).val())){
                $(this).attr('placeholder','请输入商品价格');
            }
        });

</script>

@endsection